#{extends 'main.html' /} #{set title:'Browse' /}
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Browse Ideas</title>
<!-- ---------------------javascript for browsing ideas--------------------------------------------------------------------------->
<script type="text/javascript">
	$(function() {
		$('#ideasOptions').hide();
		$('#ideasOptions').slideDown(1000);
		javascript: showIdeasCreated();
		$('#createdIdeas').hide();
	});
</script>

<script>
 function showThisAndHideAll(option){
	 if(option == 'createdIdeas')
		 {
		 $('#createdIdeas').toggle(1000);
		 }
	 if(option == 'commentedIdeas') {
		 $('#createdIdeas').hide(1000);
	 }
 }
</script>

<script type="text/javascript">
	function showIdeasCreated() {
		var user = '${user}';
		$
				.getJSON(
						'@{BrowseController.browseIdeas()}',
						{
							'userName' : user
						},
						function(data) {
							var ideas = data.createdIdeas;
							var orgsPart = "";
							if (ideas == null || ideas == "") {
								document.getElementById("createdIdeas").innerHTML = "No ideas to show";
							} else {
								var x = ideas.split("&&");
								orgsPart = "";

								for ( var i = 0; i < x.length-1; i = i + 1) {
									var id = x[i].split("-")[0];
									var title = x[i].split("-")[1];
									orgsPart += "<a href=\"@{TopicIdeaController.checkAuthorizationToViewIdea()}?ideaId=" + id +"\">" + title + "</a></p>";
								}
								document.getElementById("createdIdeas").innerHTML = orgsPart;
							}
						});
	}
</script>
</head>
<body>
<p id="ideasOptions">
		<a href='#' onclick="showThisAndHideAll('createdIdeas')"> CreatedIdeas</a> 
	</p>

<div id="createdIdeas"></div>
	<div id="commentedIdeas"></div>
</body>
